<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"><meta name="referrer" content="no-referrer" />
    <title>评论页面</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <style>
        .left-side {
            position: fixed;
            top: 0;
            bottom: 0;
            z-index: 5;
            display: block;
            width: 240px;
            font-weight: 500;
        }

        ul {
            list-style: none;
        }
    </style>
    <script>
        $(function () {
            console.log("进入头部");
            $(".header").load("adminHeadHtml");
            $.ajax({
                url: "/getComments",
                type: "POST",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result != null) {
                        $imgs = $(".comments");
                        var li = '';
                        for (let i = 0; i < result.length; i++) {
                            li = li + '<a href="#" onclick="huifuchuxian(' + result[i].id + ')"><div id="contentCon" style="margin: 0 auto;height: fit-content">\n' +
                                '                                <p id="title" style="font-size: 30px">>> ' + result[i].user + '</p>\n' +
                                '                                <p id="content">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result[i].com + '</p>\n' +
                                '                                <p id="date" style="float: right">' + rTime(result[i].date) + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></br>\n' +
                                '                            </div></a></br>' +
                                '                                <div id="response' + result[i].id + '" style="display: none;">' +
                                '<div class="comment-form"><textarea class="commentres' + result[i].id + '" style="width: 100%;margin: 0 auto;height: fit-content;"></textarea></div></div>\n\n' +
                                '<a id="xianshi" onclick="gengduo(' + result[i].id + ')" href="#">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;更多</a><a id="xianshi" onclick="shouqi(' + result[i].id + ')" href="#">&nbsp;&nbsp;收起</a><div id="responses' + result[i].id + '" style="background-color: #d2ffac;width: 80%;"></div>';
                        }
                        $imgs.html(li);
                    }
                }
            });

        });
        function gengduo(a){
            $.ajax({
                url: "/getResponses",
                type: "POST",
                data: JSON.stringify({"id": a}),
                contentType: "application/json",
                dataType: "json",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result != null) {
                        $imgs = $("#responses" + a);
                        var li = '';
                        for (let i = 0; i < result.length; i++) {
                            li = li + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result[i].user + '回复' + result[i].lastuser + ':' + result[i].com + rTime(result[i].date) + '</br>';
                        }
                        $imgs.html(li);
                    }
                }
            });
        }
        function shouqi(a){
            $.ajax({
                url: "/getResponses",
                type: "POST",
                data: JSON.stringify({"id": a}),
                contentType: "application/json",
                dataType: "json",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result != null) {
                        $imgs = $("#responses" + a);
                        var li = '';
                        $imgs.html(li);
                    }
                }
            });
        }
        function rTime(date) {
            var json_date = new Date(date).toJSON();
            return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
        }
    </script>
</head>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <h1 style="text-align: center;color: #33cabb;">Spider</h1>
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <nav class="sidebar-main">
                    <ul class="nav nav-drawer" style="list-style: none">
                        <li class="nav-item active"><a href="/adminNotice"><i class="mdi mdi-home"></i>公告管理</a></li>
                        <li class="nav-item active"><a href="/toFindAllUsers"><i class="mdi mdi-home"></i>用户管理</a></li>
                        <li class="nav-item active"><a href="/adminComment"><i class="mdi mdi-home"></i>查看反馈</a></li>
                        <li class="nav-item active submenu"><a href="#"><i class="mdi mdi-home"></i>个人中心</a>
                            <ul class="nav nav-drawer">
                                <li class="nav-item active"><a href="/toSelf">&nbsp&nbsp&nbsp&nbsp<i
                                        class="mdi mdi-step-forward"></i>信息编辑</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>
        <!--End 左侧导航-->
        <!--头部信息-->
        <div class="header"></div>
        <!--End 头部信息-->
        <!-- 主题内容 -->
        <!--页面主要内容 table table-striped table-hover-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="comment-form">
                                用户评论：
                            </div>
                            <div class="comments"></div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
</html>